package com.vinjogames.entities;

import javax.microedition.khronos.opengles.GL10;

import com.vinjogames.gfx.Image;
import com.vinjogames.util.GameConVars;

public class Resource extends GameObject {
	int resourcesPerTurn;
	Player owner;
	int captureMaxPerTurn;
	int capturePointsRequired;
	int captureProgress;
	boolean captureStatus;
	
	public Resource(float x, float y) {
		super(GameConVars.OBJECT_RESOURCE);
		this.mGLWidth = GameConVars.MAP_RESOURCE_WIDTH;
		this.mGLHeight = 2;
		this.mImage = new Image(GameConVars.GRAPHIC_RESOURCE, mGLWidth, mGLHeight);
		this.setX(x);
		this.setY(y);
	
		//todo:
		capturePointsRequired = 4;
		captureProgress = 2;
	}
	
	public boolean captureResource(Player p, int points) {
		captureProgress += points;
		
		if(captureProgress >= capturePointsRequired){
			owner = p;
			return true;
		}
		return false;
	}
	
	public void draw(GL10 gl) {
		//Capture bar
		//Some indicator of owner
		
		int r = owner == null ? 0: 1; //Temp indicator of ownership
		mImage.draw(gl, mLocation.x, mLocation.y + .7f, r, 1, 1, 1);

		
		
		
		if(captureProgress > 0){
			drawBars(gl, mLocation.x, mLocation.y + mGLHeight/2, mGLWidth, mGLHeight,captureProgress/capturePointsRequired, 0,0,1,1);
		}
	}
	
	public void clearInfo() {}
}
